package com.itheima;

/**
 * @auther Macrydy
 * @date 2020/6/29 21:22
 * 递归
 */
public class DiGui {
    public static void main(String[] args) {
        int result1 = method1(5);
        System.out.println(result1);
        int result2 = method2(100);
        System.out.println(result2);
    }

    //求和
    private static int method2(int i) {
        if (i==1){
            return 1;
        }else {
            return i+method2(i-1);
        }
    }

    //求乘阶
    private static int method1(int i) {
        if (i==1){
            return 1;
        }else {
            return i*method1(i-1);
        }

    }

}
